import React, { Component } from 'react';
import {Redirect} from 'react-router-dom'

import {NavBar, InputItem, TextareaItem,Button}  from 'antd-mobile'
import AvatarSelector from '../../components/avatar-selector/avatar-selector'
import {connect} from 'react-redux'
import {update} from '../../redux/user.redux'
@connect(
  state => state.user,
  {update}
)
class GeniusInfo extends Component {
  constructor(props){
    super(props)
    this.state = {
      title:'',
      desc:''
    }
    this.handleChange = this.handleChange.bind(this)
  }
  handleChange(key,val){
    this.setState({
          [key]:val
      })
  }

  render() {
    const path = this.props.location.pathname
    const redirect = this.props.redirectTo
    return (
      <div>
         {redirect && path !== redirect ? <Redirect to={this.props.redirectTo} /> : null}
        <NavBar
          mode="dark"
        >牛人 完善信息</NavBar>
        <AvatarSelector
          selectAvatar={name=>{
            this.setState({
              avatar:name
            })
          }}
        ></AvatarSelector>
        <InputItem onChange={v=>this.handleChange('title',v)}>
          求职岗位
        </InputItem>
        <TextareaItem onChange={v=>this.handleChange('desc',v)} autoHeight title="个人简介" rows={3} >
         
        </TextareaItem>

        <Button onClick={()=>{
            this.props.update(this.state)
          }} type="primary" >保存</Button>
      </div>
    );
  }
}

export default GeniusInfo;